package org.ihelpuoo.http;

import javax.servlet.http.HttpServletRequest;

public class BrowserDetector
{
	private static BrowserDetector	bd	= null;

	public static BrowserDetector getInstance()
	{
		if (null == bd)
			synchronized (HTTP.class)
			{
				if (null == bd)
					bd = new BrowserDetector();
			}
		return bd;
	}

	public String getLogogram(HttpServletRequest request)
	{
		String ua = HTTP.getUserAgent(request);
		return getLogogram(ua);
	}

	public String getLogogram(String ua)
	{
		if (isIE(ua))
			return "IE";
		else if (isFirefox(ua))
			return "FF";
		return null;
	}

	public boolean isIE6(String userAgent)
	{
		return userAgent.indexOf("MSIE 6.0") > 0;
	}

	public boolean isIE7(String userAgent)
	{
		return userAgent.indexOf("MSIE 7.0") > 0;
	}

	public boolean isIE(String userAgent)
	{
		return userAgent.indexOf("MSIE") > 0;
	}

	public boolean isFirefox(String userAgent)
	{
		return userAgent.indexOf("Firefox") > 0;
	}

	public boolean isFirefox1(String userAgent)
	{
		return userAgent.indexOf("Firefox/1") > 0;
	}

	public boolean isFirefox2(String userAgent)
	{
		return userAgent.indexOf("Firefox/2") > 0;
	}

	public boolean isGecko(String userAgent)
	{
		return userAgent.indexOf("Gecko") > 0;
	}
}
